{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from sympy import *\n",
    "init_printing()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAA6cAAABMBAMAAABjWdyfAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAMquZdlQQ3SJEie/N\nZrv3ZvUrAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAPr0lEQVR4Ae1df4hlVR3/vp2d99783MkMqdVm\nNbGiYqdcKqzkUSPUYLSQErSgUyqEq45Q0VLG3pAgWFynP2JBqR3WjVQU1qxlFwpflEo11ET9IWn4\nyEUCS9dRQ618fc+559c993zv+d47d3Zn5B2Yd8+993O+38/3fO6vN/PZuzDd76/CoL1ZZqDV7/cB\npnfNXvFmqWhQB0zMzu5EUacGU/HmmoGnKVEvwDpvXpHFThCqMyC5yWKMYUBs2Ci4gTU0/5YO+JMd\n5/YYEA2PpoM4QscCYCSuBKFEbfcARp79fErgQsvD6TEgEt34mR3EGBOFxONt79iMB7H7oxtm5IYt\n4aOzGBJPF0dYOlArNxk3T58SdXweYPv8NvzENi4//Q8GRA5pvG5HMsZEIfF400s242N4QhyHf6cb\nuna70yuGxNPFEU6yWrnJuHn6lKhziP82bNsth21dkgvvgwHxRgAwxoQhX8mFkhvCYAcrqLdW4JV0\nk4DnGgOix0TThQtsJjpAZslIXA1CiXoCYOIYbMMbErbmsQwZtcKA5IYxxoQhV+VCyQ1hsIMdSwCe\nBPhfummvs8d0GRCNjaaDIGK4owNklozE1SCEqCO34gE+A9PpmQqPZsikKwxICmy/xYxmjCEgjqjx\neN+ZMhkPYe+r0FBn6riqx+wWnQgkni6KcEWtlRtBX4t63f0/hubRuUU496orETo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\nhaIOU9Ziwr9dmUVmIOXxtuZnvB9ljOXiQSn6kvBMjnVe8QkGnO80xPq2q7IsFjX+KumqeQvG7aFc\n4Mb87BvLR3fo94gbC3VB/DOwyycYcL4XQMLG8hK0C0UlrcXSlpj3b5fIWwAlPd7W/OwZy1kvCS/I\nWP8uj2DI+U5CrG+7Kq9CUf2gxjfM9G/746ut70uHFZmfFQRoG3i11LWNYsychhT4trl0SomqfcNc\n/zaXRDFOO6gLzM8aQtvAi1Os+17GzGlIgW+bS7OUqNqlWvQqaW5iPm4ySbEF5mcNoW3g/HTrg2Q4\n3xm+bSa3cqKKv+PqpidSr6/bst1zQgdd4AwbuBPirHQZM8eAMKmXE7WN3x10e0J31n0Z90czTNbr\nzrI4AWPmGJDiHGZvOVHNsEFnI8+AELXfX93IFAfcSs1Aqy/+95HrZ2c/U2rYALyRZ2BidnYW/g9o\nKMBQ2em6pwAAAABJRU5ErkJggg==\n",
      "text/latex": [
       "$$\\left[\\begin{matrix}\\cos{\\left (\\theta_{1} \\right )} \\cos{\\left (\\theta_{2} \\right )} & - \\sin{\\left (\\theta_{1} \\right )} \\cos{\\left (\\theta_{3} \\right )} + \\sin{\\left (\\theta_{2} \\right )} \\sin{\\left (\\theta_{3} \\right )} \\cos{\\left (\\theta_{1} \\right )} & \\sin{\\left (\\theta_{1} \\right )} \\sin{\\left (\\theta_{3} \\right )} + \\sin{\\left (\\theta_{2} \\right )} \\cos{\\left (\\theta_{1} \\right )} \\cos{\\left (\\theta_{3} \\right )}\\\\\\sin{\\left (\\theta_{1} \\right )} \\cos{\\left (\\theta_{2} \\right )} & \\sin{\\left (\\theta_{1} \\right )} \\sin{\\left (\\theta_{2} \\right )} \\sin{\\left (\\theta_{3} \\right )} + \\cos{\\left (\\theta_{1} \\right )} \\cos{\\left (\\theta_{3} \\right )} & \\sin{\\left (\\theta_{1} \\right )} \\sin{\\left (\\theta_{2} \\right )} \\cos{\\left (\\theta_{3} \\right )} - \\sin{\\left (\\theta_{3} \\right )} \\cos{\\left (\\theta_{1} \\right )}\\\\- \\sin{\\left (\\theta_{2} \\right )} & \\sin{\\left (\\theta_{3} \\right )} \\cos{\\left (\\theta_{2} \\right )} & \\cos{\\left (\\theta_{2} \\right )} \\cos{\\left (\\theta_{3} \\right )}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡cos(θ₁)⋅cos(θ₂)  -sin(θ₁)⋅cos(θ₃) + sin(θ₂)⋅sin(θ₃)⋅cos(θ₁)  sin(θ₁)⋅sin(θ₃) \n",
       "⎢                                                                             \n",
       "⎢sin(θ₁)⋅cos(θ₂)  sin(θ₁)⋅sin(θ₂)⋅sin(θ₃) + cos(θ₁)⋅cos(θ₃)   sin(θ₁)⋅sin(θ₂)⋅\n",
       "⎢                                                                             \n",
       "⎣   -sin(θ₂)                   sin(θ₃)⋅cos(θ₂)                             cos\n",
       "\n",
       "+ sin(θ₂)⋅cos(θ₁)⋅cos(θ₃)⎤\n",
       "                         ⎥\n",
       "cos(θ₃) - sin(θ₃)⋅cos(θ₁)⎥\n",
       "                         ⎥\n",
       "(θ₂)⋅cos(θ₃)             ⎦"
      ]
     },
     "execution_count": 16,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "th1, th2, th3 = symbols('theta_1, theta_2, theta_3')\n",
    "dcm_321 = Matrix([[cos(th1)*cos(th2),\n",
    "         cos(th1)*sin(th2)*sin(th3) - sin(th1)*cos(th3),\n",
    "         cos(th1)*sin(th2)*cos(th3) + sin(th1)*sin(th3)],\n",
    "        [sin(th1)*cos(th2),\n",
    "         sin(th1)*sin(th2)*sin(th3) + cos(th1)*cos(th3),\n",
    "         sin(th1)*sin(th2)*cos(th3) - cos(th1)*sin(th3)],\n",
    "        [-sin(th2),\n",
    "        cos(th2)*sin(th3),\n",
    "        cos(th2)*cos(th3)]\n",
    "    ])\n",
    "dcm_321"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "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\\cos{\\left (\\theta \\right )} & \\sin{\\left (\\phi \\right )} \\sin{\\left (\\theta \\right )} \\cos{\\left (\\psi \\right )} - \\sin{\\left (\\psi \\right )} \\cos{\\left (\\phi \\right )} & \\sin{\\left (\\phi \\right )} \\sin{\\left (\\psi \\right )} + \\sin{\\left (\\theta \\right )} \\cos{\\left (\\phi \\right )} \\cos{\\left (\\psi \\right )}\\\\\\sin{\\left (\\psi \\right )} \\cos{\\left (\\theta \\right )} & \\sin{\\left (\\phi \\right )} \\sin{\\left (\\psi \\right )} \\sin{\\left (\\theta \\right )} + \\cos{\\left (\\phi \\right )} \\cos{\\left (\\psi \\right )} & - \\sin{\\left (\\phi \\right )} \\cos{\\left (\\psi \\right )} + \\sin{\\left (\\psi \\right )} \\sin{\\left (\\theta \\right )} \\cos{\\left (\\phi \\right )}\\\\- \\sin{\\left (\\theta \\right )} & \\sin{\\left (\\phi \\right )} \\cos{\\left (\\theta \\right )} & \\cos{\\left (\\phi \\right )} \\cos{\\left (\\theta \\right )}\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡cos(ψ)⋅cos(θ)  sin(φ)⋅sin(θ)⋅cos(ψ) - sin(ψ)⋅cos(φ)  sin(φ)⋅sin(ψ) + sin(θ)⋅c\n",
       "⎢                                                                             \n",
       "⎢sin(ψ)⋅cos(θ)  sin(φ)⋅sin(ψ)⋅sin(θ) + cos(φ)⋅cos(ψ)  -sin(φ)⋅cos(ψ) + sin(ψ)⋅\n",
       "⎢                                                                             \n",
       "⎣   -sin(θ)                sin(φ)⋅cos(θ)                          cos(φ)⋅cos(θ\n",
       "\n",
       "os(φ)⋅cos(ψ) ⎤\n",
       "             ⎥\n",
       "sin(θ)⋅cos(φ)⎥\n",
       "             ⎥\n",
       ")            ⎦"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "phi, theta, psi = symbols('phi, theta, psi')\n",
    "sub_eulers = {\n",
    "    th1: psi, th2: theta, th3: phi\n",
    "}\n",
    "dcm_321_euler = dcm_321.subs(sub_eulers)\n",
    "dcm_321_euler"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 38,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOAAAABLCAMAAABeKHv+AAAAPFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAo1xBWAAAAE3RSTlMA\nMquZdlQQQOkwRInN3SJm77tsdo1uFAAAAAlwSFlzAAAOxAAADsQBlSsOGwAABf5JREFUeAHtnOuW\nrCgMhVHROVNaXsb3f9cJAULQoKKWq1efqh+9UHGHj0uU3dWtihk/pfpln7flUqqYKw2f+pfxqcFQ\nlbMBLB5jK4YQykUdLkZfS3LFQQJsqlZXl8IWow4grNRP7KB15fJSKEmSKYqAHczW5t2ztuQWi9m3\nPr6za9gxVenYyeyiKBkUJcBhNFHaUCk7aOoGTUxQo6fZGp1O3Zs4H91LkuGsBDhhPq1n3tsJ+czT\nI58VAx002KOZWq66LBkUJcAZAV/zhbTaF9K6er05BBtNsybOfVKSpCgANnNlgr1mOU9sNqTQtdad\n6ifTSUU3VgUkatJpUVg1bWVOAaB2xO6CIA35rm0NftNq3b6g4EK4uilJUhQAe5sgUnlCaAWdajBJ\nmlbbad5NQNLPfi5OdtW1qobc3UOztVsGQ2q99yPUKmAaFpjzQC6EwKgpSVK8F/A1mnVr5p4FnHBx\nzT6bvHEmAlkFfTCYqm7x1dHcxZbbH50hr+E5/cYJDU/sEAJrpCRJUQBs7AjuT9Gme9Ons2vuPU8a\nx8sB4sjQXB/NFFMANkJzscV2zsKrBrZ29cOtFvMugn2joGkUAmunJElRAFR2DdZnkkzTdjPe7gBx\nyi4AzfKGTjCAjVue1JwFInVyPWPfqHmCxehCMMC1JClKgG9s1nDiMdGb0RtMY0RAO5+ADWakWYKq\ndU+iOBcGy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jWIP9dOokfLtxvIVPog9JbgM1UldcA77eQie+o9BYgiPnvO5JuXsFuUu+0kCn+UenPAt5uIROf\nOir9UcB8CzkA7JQOS38UMNtC3qFilw9L/1WAwjd4ryWZXAuZjdBe8bD0R0fwyneH9wiPutOfBcy0\nkPeg+PWj0p8FzLWQOcFO+aj0ZwFzLeQdqOjywa8lbwJW5Ti/zTewT39Of3d4P+JB6U3A/Sg/v8YX\n8OeP0XYLvyO43T8//+pfMoK//B8FNOYP6rVO/vXJz5+HcgvxHwVorf4H0vBNtTc/I9gAAAAASUVO\nRK5CYII=\n",
      "text/latex": [
       "$$\\left[\\begin{matrix}0 & - \\sin{\\left (\\psi \\right )} & \\cos{\\left (\\psi \\right )}\\\\0 & \\cos{\\left (\\psi \\right )} & \\sin{\\left (\\psi \\right )}\\\\-1 & 0 & 0\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡0   -sin(ψ)  cos(ψ)⎤\n",
       "⎢                   ⎥\n",
       "⎢0   cos(ψ)   sin(ψ)⎥\n",
       "⎢                   ⎥\n",
       "⎣-1     0       0   ⎦"
      ]
     },
     "execution_count": 38,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dcm_pitch_up = dcm_321_euler.subs({theta:pi/2, phi:0})\n",
    "dcm_pitch_up"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 39,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMUAAAAVBAMAAAAEKDfsAAAAMFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAv3aB7AAAAD3RSTlMAZnaJVN0imavvMkQQ\nzbsZbzSbAAAACXBIWXMAAA7EAAAOxAGVKw4bAAADfUlEQVRIDcVVS4gUVxQ91VVdM139mWYWGvLB\n0iEhi4ilJo6QQJqQ4CLgNCi69AlukoUZxi9Z6JAsEtzYQYkhcdG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omo6y4Oak6CVWFUhG3LuuU0lxsnoMJ0n8L\ngh2TMOlHW7WANeYTnXDuNRzecvUAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\operatorname{atan_{2}}{\\left (\\sin{\\left (\\psi \\right )},\\cos{\\left (\\psi \\right )} \\right )}$$"
      ],
      "text/plain": [
       "atan2(sin(ψ), cos(ψ))"
      ]
     },
     "execution_count": 39,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "atan2(dcm_pitch_up[1,2], dcm_pitch_up[0,2])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 40,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAOAAAABLCAMAAABeKHv+AAAAPFBMVEX///8AAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAo1xBWAAAAE3RSTlMA\nMquZdlQQQOkwRInN3SJm77tsdo1uFAAAAAlwSFlzAAAOxAAADsQBlSsOGwAABf5JREFUeAHtnOuW\nrCgMhVHROVNaXsb3f9cJAULQoKKWq1efqh+9UHGHj0uU3dWtihk/pfpln7flUqqYKw2f+pfxqcFQ\nlbMBLB5jK4YQykUdLkZfS3LFQQJsqlZXl8IWow4grNRP7KB15fJSKEmSKYqAHczW5t2ztuQWi9m3\nPr6za9gxVenYyeyiKBkUJcBhNFHaUCk7aOoGTUxQo6fZGp1O3Zs4H91LkuGsBDhhPq1n3tsJ+czT\nI58VAx002KOZWq66LBkUJcAZAV/zhbTaF9K6er05BBtNsybOfVKSpCgANnNlgr1mOU9sNqTQtdad\n6ifTSUU3VgUkatJpUVg1bWVOAaB2xO6CIA35rm0NftNq3b6g4EK4uilJUhQAe5sgUnlCaAWdajBJ\nmlbbad5NQNLPfi5OdtW1qobc3UOztVsGQ2q99yPUKmAaFpjzQC6EwKgpSVK8F/A1mnVr5p4FnHBx\nzT6bvH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\n8aPg80pWsrd91dJKJt9XSjL2l405r8KX3VmOFJe9zytbyWEmpnxfGTCOccPRnjt7OkQQVtxKDr7v\nQ4B77uxpwCCsuJUcfN+HAEXDl7mzpwGDMHsRVVxZyqLnwyXvpH0pM3yZO5u8b/cCCZtfV/kPV34I\nMGwCfSPC3obOnCrQHjDcTbsmc+opwBD+4dIX8OEOvz3cdwRv79KHBf/6EYx9x+zev99CpiYclN4e\nQfjWIP9dOokfLtxvIVPog9JbgM1UldcA77eQie+o9BYgiPnvO5JuXsFuUu+0kCn+UenPAt5uIROf\nOir9UcB8CzkA7JQOS38UMNtC3qFilw9L/1WAwjd4ryWZXAuZjdBe8bD0R0fwyneH9wiPutOfBcy0\nkPeg+PWj0p8FzLWQOcFO+aj0ZwFzLeQdqOjywa8lbwJW5Ti/zTewT39Of3d4P+JB6U3A/Sg/v8YX\n8OeP0XYLvyO43T8//+pfMoK//B8FNOYP6rVO/vXJz5+HcgvxHwVorf4H0vBNtTc/I9gAAAAASUVO\nRK5CYII=\n",
      "text/latex": [
       "$$\\left[\\begin{matrix}0 & - \\sin{\\left (\\psi \\right )} & \\cos{\\left (\\psi \\right )}\\\\0 & \\cos{\\left (\\psi \\right )} & \\sin{\\left (\\psi \\right )}\\\\-1 & 0 & 0\\end{matrix}\\right]$$"
      ],
      "text/plain": [
       "⎡0   -sin(ψ)  cos(ψ)⎤\n",
       "⎢                   ⎥\n",
       "⎢0   cos(ψ)   sin(ψ)⎥\n",
       "⎢                   ⎥\n",
       "⎣-1     0       0   ⎦"
      ]
     },
     "execution_count": 40,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dcm_pitch_down = dcm_321_euler.subs({theta:pi/2, phi:0})\n",
    "dcm_pitch_down"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 41,
   "metadata": {
    "collapsed": false
   },
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAMUAAAAVBAMAAAAEKDfsAAAAMFBMV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/wquGavjd+1VFfK1DF5iS8+wpv/FktO/ofdzo+CHmX1r\nH47CYU13mV+++O1g/4ML+x8cu/UNKTkfb/u116R8meciR3puZBX8basb0sup/gbXrO03xEWuRbJb\n/IxTQm9I1bKGVFAR3q9xOCGoI1R1TMmPOEp2iWDy/X+EXpiq6QYzsfBuyKEsqCNU9YaSKzhKdonc\nzMy00CWTKl4no3+KcJGo0M1DVZEoC02bgp8VfitV2Uomo6y4Oak6CVWFUhG3LuuU0lxsnoMJ0n8L\ngh2TMOlHW7WANeYTnXDuNRzecvUAAAAASUVORK5CYII=\n",
      "text/latex": [
       "$$\\operatorname{atan_{2}}{\\left (\\sin{\\left (\\psi \\right )},\\cos{\\left (\\psi \\right )} \\right )}$$"
      ],
      "text/plain": [
       "atan2(sin(ψ), cos(ψ))"
      ]
     },
     "execution_count": 41,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "dcm_pitch_down = dcm_321_euler.subs({theta:-pi/2, phi:0})\n",
    "atan2(-dcm_pitch_down[1,2], -dcm_pitch_down[0,2])"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}
